import {
  CHECK_TYPE_OPTIONS,
  LEVEL_MAP,
  LINE_TYPE_OPTIONS,
  STATE_OPTIONS,
} from '@/constants/enums';
import useMaterial from '@/hooks/useMaterial';
import { Descriptions } from 'antd';
import styles from './index.less';

const BaseInfo = (props) => {
  const { data } = props;
  const { materialTypeMap } = useMaterial();

  // 获取选项的标签值
  const getOptionLabel = (options, value) => {
    const option = options.find((item) => item.value === value);
    return option ? option.label : value;
  };

  const items = [
    {
      key: '1',
      label: '线路名称',
      children: data?.lineName || '-',
    },
    {
      key: '2',
      label: '全称',
      children: data?.fullName || '-',
    },
    {
      key: '3',
      label: '装货地',
      children: data?.loadPlaceName || '-',
    },
    {
      key: '4',
      label: '卸货地',
      children: data?.unloadPlaceName || '-',
    },
    {
      key: '28',
      label: '其他卸货地',
      children: data?.unloadPlaceName2 || '-',
    },
    {
      key: '5',
      label: '线路编号',
      children: data?.lineCode || '-',
    },
    {
      key: '6',
      label: '线路类型',
      children: getOptionLabel(LINE_TYPE_OPTIONS, data?.lineType),
    },
    {
      key: '7',
      label: '物料类型',
      children: materialTypeMap[data?.type],
    },
    {
      key: '8',
      label: '空载里程',
      children: data?.emptyMileages ? `${data.emptyMileages} km` : '-',
    },
    {
      key: '9',
      label: '重载里程',
      children: data?.heavyMileages ? `${data.heavyMileages} km` : '-',
    },
    {
      key: '10',
      label: '空载时长',
      children: data?.emptyTimes ? `${data.emptyTimes} 分钟` : '-',
    },
    {
      key: '11',
      label: '重载时长',
      children: data?.heavyTimes ? `${data.heavyTimes} 分钟` : '-',
    },
    {
      key: '12',
      label: '报计划站点',
      children: data?.planStationName || '-',
    },
    {
      key: '13',
      label: '单价(元/吨)',
      children: data?.price || '-',
    },
    {
      key: '14',
      label: '司机单价(元/趟)',
      children: data?.driverPrice || '-',
    },
    {
      key: '15',
      label: '状态',
      children: getOptionLabel(STATE_OPTIONS, data?.state),
    },
    {
      key: '16',
      label: '级别',
      children: LEVEL_MAP[data?.level],
    },
    {
      key: '17',
      label: '核算类型',
      children: getOptionLabel(CHECK_TYPE_OPTIONS, data?.checkType),
    },
    {
      key: '18',
      label: '核算系数',
      children: data?.checkRatio ? `${data.checkRatio}` : '-',
    },
    {
      key: '19',
      label: '装车费',
      children: data?.loadPrice ? `${data.loadPrice} 元` : '-',
    },
    {
      key: '20',
      label: '卸车费',
      children: data?.unloadPrice ? `${data.unloadPrice} 元` : '-',
    },
    {
      key: '21',
      label: '信息费',
      children: data?.infoPrice ? `${data.infoPrice} 元` : '-',
    },
    {
      key: '22',
      label: '篷布费',
      children: data?.tarpaulinPrice ? `${data.tarpaulinPrice} 元` : '-',
    },
    {
      key: '23',
      label: '过磅费',
      children: data?.passWeightPrice ? `${data.passWeightPrice} 元` : '-',
    },
    {
      key: '24',
      label: '上车台费',
      children: data?.upCarPrice ? `${data.upCarPrice} 元` : '-',
    },
    {
      key: '25',
      label: '下车台费',
      children: data?.downCarPrice ? `${data.downCarPrice} 元` : '-',
    },
    {
      key: '26',
      label: '折损系数',
      children: data?.lossRatio ? `${data.lossRatio}` : '-',
    },
    {
      key: '27',
      label: '磅单差价',
      children: data?.discrepancyPrice ? `${data.discrepancyPrice} 元` : '-',
    },
    {
      key: '28',
      label: '其他费用',
      children: data?.otherPrice ? `${data.otherPrice} 元` : '-',
    },
    {
      key: '29',
      label: '客户单位',
      children: data?.customerName || '-',
    },
    {
      key: '30',
      label: '备注',
      children: data?.remark || '-',
    },
  ];

  return (
    <div className={styles.baseInfo}>
      <section className={styles.section}>
        <Descriptions
          items={items}
          column={2}
          bordered
          size="small"
          labelStyle={{ width: '120px', textAlign: 'right' }}
        />
      </section>
    </div>
  );
};

export default BaseInfo;
